{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "f4a26e39-5379-4b2a-9e73-a52f1edb0d90",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入列表元素（整数，可有重复，-1表示结束输入）：    3\n",
      "请输入列表元素（整数，可有重复，-1表示结束输入）：    1\n",
      "请输入列表元素（整数，可有重复，-1表示结束输入）：    2\n",
      "请输入列表元素（整数，可有重复，-1表示结束输入）：    \n"
     ]
    },
    {
     "ename": "ValueError",
     "evalue": "invalid literal for int() with base 10: ''",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "Cell \u001b[0;32mIn[1], line 12\u001b[0m\n\u001b[1;32m     10\u001b[0m \u001b[38;5;28;01mwhile\u001b[39;00m(a\u001b[38;5;241m!=\u001b[39m\u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m):\n\u001b[1;32m     11\u001b[0m     list1\u001b[38;5;241m.\u001b[39mappend(a)\n\u001b[0;32m---> 12\u001b[0m     a\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;43mint\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;28;43minput\u001b[39;49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43m请输入列表元素（整数，可有重复，-1表示结束输入）：   \u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m     13\u001b[0m list2\u001b[38;5;241m=\u001b[39m[]\n\u001b[1;32m     14\u001b[0m \u001b[38;5;28;01mfor\u001b[39;00m i \u001b[38;5;129;01min\u001b[39;00m list1:\n",
      "\u001b[0;31mValueError\u001b[0m: invalid literal for int() with base 10: ''"
     ]
    }
   ],
   "source": [
    "##list1=[1,2,3,2,3,4]\n",
    "##set1=set(list1)\n",
    "##list1=list(set1)\n",
    "\n",
    "\n",
    "#list1=[1,2,3,2,3,4]\n",
    "\n",
    "list1=[]\n",
    "a=int(input(\"请输入列表元素（整数，可有重复，-1表示结束输入）：   \"))\n",
    "while(a!=-1):\n",
    "    list1.append(a)\n",
    "    a=int(input(\"请输入列表元素（整数，可有重复，-1表示结束输入）：   \"))\n",
    "list2=[]\n",
    "for i in list1:\n",
    "    if i not in list2:\n",
    "        list2.append(i)\n",
    "print(list2)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4f299e52-3f77-452d-ab70-477be84cb838",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
